package crew.blt.handsound.shared.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import crew.gwt.client.domain.PersistableEntity;

public class User implements PersistableEntity<User>,Serializable {
	private String id;
	private String username;
	private String firstName;
	private String lastName;
	private String password;
	private String email;
	private String dateCreated;
	
	private boolean enabled;

	private Set<Auth> auths;
	
	public User(){
		
	}

	public User(String username, String firstname, String lastname, String email,String pwd, Boolean enabled) {
		this.username = username;
		this.firstName = firstname;
		this.lastName = lastname;
		this.email = email;
		this.password = pwd;
		this.enabled = enabled;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getId() {
		return id;
	}
	public void setId(String idUser) {
		id = idUser;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String first) {
		firstName = first;
	}
	public  String getLastName() {
		return lastName;
	}
	public  void setLastName(String last) {
		lastName = last;
	}
	public  String getPassword() {
		return password;
	}
	public  void setPassword(String passw) {
		password = passw;
	}

	public String getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(String dateCreated) {
		this.dateCreated = dateCreated;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	
	public Set<Auth> getAuths() {
		if (auths == null)
			auths = new HashSet<Auth>();
		return auths;
	}

	public void addAuth(Auth auth) {
		if (auths == null)
			auths = new HashSet<Auth>();
		this.auths.add(auth);
	}

	@Override
	public User getCopy() {
		return new User(getUsername(),getFirstName(),getLastName(),getEmail(),getPassword(),isEnabled());
	}

	@Override
	public String[] getHeadersValues() {
		return new String[]{"id"," username"," firstName"," lastName"," password"," email","enabled"};
	}

	@Override
	public String getIdFieldName() {
		return "id";
	}

	@Override
	public String[] getValues() {
		return new String[]{getId(),getUsername(),getFirstName(),getLastName(),getPassword(),getEmail(),String.valueOf(isEnabled())};
	}
}
